package edu.govschool2010.screens;



import java.util.ArrayList;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class MainScreen extends ListActivity {
	
	//ArrayList<Situation> list = new ArrayList<Situation>();
	ListView lv = null;
	ArrayList<String> situations = null;
	ArrayAdapter<String> adapter = null;
	String string = "blah";
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        //ReadFromFile.readFromFile(list); Call to Eric's method to populate array
        
        lv = (ListView)findViewById(R.id.sit_ListView);
        situations = new ArrayList<String>();
        
        /*for (int i = 0; i < list.size(); i++) {
        	situations.add(list[i].situationName);
        }*/
        
        situations.add("Add Situation. . .");
        
        Context c = getApplicationContext();
        
        LayoutInflater inflater = (LayoutInflater)c.getSystemService(LAYOUT_INFLATER_SERVICE);
        
        View layout = inflater.inflate(R.layout.list_item, (LinearLayout)findViewById(R.id.listItemLayout));
        
        adapter = new ArrayAdapter<String>(this, R.layout.list_item, situations);
        lv.setAdapter(adapter);
        
        
        
        lv.setOnItemClickListener(new OnItemClickListener(){
        	public void onItemClick(AdapterView<?> a, View v, int x, long id)
        	{
        		Intent intent = new Intent(MainScreen.this, NewSituation.class);
        		startActivity(intent);
        	}
        });

    }
    
}